/*
 * WxClient.hpp
 *
 *  Created on: May 31, 2013
 *      Author: ken
 */

#ifndef WXCLIENT_HPP_
#define WXCLIENT_HPP_

#include "wx/wx.h"
#include "wx/textctrl.h"
#include "wx/listbox.h"
#include "ClientCommands.hpp"
#include "wxDefaultValues.hpp"
#include "Connection.hpp"


class MainApp: public wxApp {
public:
	virtual bool OnInit();
};

class MainFrame: public wxFrame {
public:
	MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size);

	//TODO some methods can be private
	void errorBox(int code);
	void errorBoxClient(int error);
	bool checkExists(std::string fileName, wxCheckListBox* list);
	wxCheckListBox *clientList;
	wxCheckListBox *serverList;

private:
	Connection con;
	int rCode;
	wxSize screenSize;
	ClientCommands cc;

	wxStaticText *IPPortText;
	wxStaticText *usernameText;
	wxStaticText *passwordText;

	wxButton *connectButton;
	wxButton *logonButton;
	wxButton *cancelButton;
	wxTextCtrl *ip;
	wxTextCtrl *port;
	wxTextCtrl *username;
	wxTextCtrl *password;
	wxCheckBox *saveLoginData;

	wxButton *uploadButton;
	wxButton *downloadButton;
	wxButton *deleteServerButton;
	wxButton *renameServerButton;
	wxButton *deleteClientButton;
	wxButton *renameClientButton;
	wxButton *addDirClientButton;
	wxButton *addDirServerButton;
	wxButton *refreshButton;

	std::string currentClientDirectory;
	std::string currentServerDirectory;

	wxString clientDir;
	wxStaticText *clientDirText;
	wxString serverDir;
	wxStaticText *serverDirText;

	DECLARE_EVENT_TABLE()

	void createConnectScreen();
	void createMainScreen();
	void logon(wxCommandEvent& event);
	void cancel(wxCommandEvent& event);

	void upload(wxCommandEvent& event);
	void download(wxCommandEvent& event);
	void refresh(wxCommandEvent& event);
	void deleteServer(wxCommandEvent& event);
	void deleteClient(wxCommandEvent& event);
	void renameServer(wxCommandEvent& event);
	void renameClient(wxCommandEvent& event);
	void addDirServer(wxCommandEvent& event);
	void addDirClient(wxCommandEvent& event);
	void changeDirClient(wxCommandEvent& event);
	void changeDirServer(wxCommandEvent& event);
	void getClientStruct(std::string folder);
	int getServerStruct();
	std::vector<std::string> getDirStructure(std::string dir);

	void writeConfig();


};

#endif /* WXCLIENT_HPP_ */
